package com.s06.homework.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import com.s06.homework.model.User;

public class UserUtils {
	
	public static User[] buildUsers(String[] strings){
		
		User[] users = new User[strings.length];
		
		for (int i = 0; i < strings.length; i++) {
			String string = strings[i];
			
			User user = new User(string);
			users[i] = user;
		}
		return users;		
	}
	
	public static Integer getAge(String dob){		
		Date now = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		int currentYear = Integer.parseInt(sdf.format(now));
		String[] dobYear = dob.split("-");		
	
		return currentYear - Integer.parseInt(dobYear[2]);
	}
}